﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;

namespace GrayParrot.Web.Controls
{
    /// <summary>
    /// Generic CRUD controller class for JQDatatable grid...
    /// </summary>
    /// <typeparam name="T">The Entity type for Add, Edit and Delete commands</typeparam>
    /// <typeparam name="P">The Parameter type for loading data in grid</typeparam>
    public abstract class GridCrudController<T, P> : ApiController where T : class
    {
        [HttpPost]
        public abstract HttpResponseMessage Load(P data);

        [HttpPost]
        public abstract HttpResponseMessage Add(T data);

        [HttpPost]
        public abstract HttpResponseMessage Edit(T data);

        [HttpPost]
        public abstract HttpResponseMessage Delete([FromUri] int id);

        [HttpPost]
        public abstract HttpResponseMessage Delete(JObject data);
    }
}
